<!--
        File        : CategoryList.xsl
        Created     : 12.6.2014
        Author      : Martin Ribarič
        Description : XSLT script for transformation
-->
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
    <xsl:template match="videolibrary">
        <table id="list" border="1">
            <thead>
                <th colspan="1">Category</th>
                <th colspan="0">Mediums</th>
            </thead>
            <xsl:apply-templates select="category"/>
        </table>
    </xsl:template>
        
    <xsl:template match="category">
        <tr>
            <td>
                <xsl:value-of select="@name"/>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test=".//medium">
                        <xsl:apply-templates select="mediums"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <p>Empty Category</p>
                    </xsl:otherwise>
                </xsl:choose>
            </td>
        </tr>
    </xsl:template>
    
    <xsl:template match="mediums">
        <table style="width: 100%">
            <tr>
                <xsl:for-each select="medium">
                    <td style="border: 1px solid black">
                        <xsl:value-of select="@label"/>
                    </td>
                </xsl:for-each>
            </tr>
        </table>
    </xsl:template>

</xsl:transform>